package com.cosina.game.crystallight.util;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;

public class CanvasUtil {
	public static void drawText(Canvas canvas, Object content, int locationX, int locationY, Paint paint ,int textSize){
		paint.setTextSize(textSize);

		String contentStr = content.toString();
		
		float width = paint.measureText(contentStr);
		
		canvas.drawText(contentStr, locationX - width/2, locationY, paint);
	}
	
	public static void drawText(Canvas canvas, Object content, Point location, Paint paint ,int textSize){
		drawText(canvas, content, location.x, location.y, paint, textSize);
	}

	public static void drawAlphaBitmap(Canvas canvas, Bitmap bitmap, int x, int y,
			Paint paint, int alpha) {
		int alphaBack = paint.getAlpha();
		paint.setAlpha(alpha);
		canvas.drawBitmap(bitmap, x, y, paint);
		paint.setAlpha(alphaBack);
	}
}
